Skip to content

Conversation

@brendan-m-murphy
Copy link
Owner

Description

Related Issue

  • Closes #
  • Related to #

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

Armavica and others added 24 commits April 3, 2024 10:53
Also removes special case for old unsupported numpy 1.16
Numpy 2.0 uses C99 complex variables, which come in three varieties:
complex floats, complex doubles, and complex long doubles. Numpy
defines corresponding types: npy_cfloat, npy_cdouble, npy_clongdouble.

We need to translate between these sizes and bit-width sizes,
like npy_complex64 and npy_complex128. The alises added do so,
as least in the cases where doubles have 32 or 64 bits
Updated pytensor_complex struct to use get/set real/imag
aliases defined above.

Note: redefining the complex arithmetic here means that we
aren't treating NaNs and infinities as carefully as the C99
standard suggets (see Appendix G of the standard).

The code has been like this since it was added to Theano,
so we're keeping the existing behavior.
We need the bit width of the complex types so that
we can choose the right get/set operators
Many more tests pass after fixing this.
Github merge added back some changes from the
commit that removed custom complex types, which
caused some tests to start failing again.
The macros select based on the underlying numpy
type, so we don't need to find this explicitly, like
the previous solution was doing.
These need to be copied into the source code
since they're not available in Numpy 1.x.

They define macros with the Numpy 1.x behavior
for getting real and imaginary parts. In Numpy 2.0
these macros are already defined with the new definitions,
so this addition to our code will be ignored in Numpy 2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants